<?php

/**
 * Skeleton subclass for representing a row from the 'car_damages' table.
 *
 *
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.damages
 */
class DamagesCarDamages extends DamagesBaseCarDamages {

  public function save(PropelPDO $con = null) {
    $this->setLogs();
    return parent::save($con);
  }

  private function setLogs() {

    foreach ($this->getModifiedColumns() as $column) {
      switch ($column) {
        case DamagesCarDamagesPeer::DAMAGES_DESCRIPTION:
          Damages_CarDamageLog::logEvent($this->getId(), Damages_CarDamageLog::PATTERN_CAR_DAMAGE_DAMAGE_DESCRIPTION, Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::DAMAGE_DATE:
          Damages_CarDamageLog::logEvent($this->getId(), Damages_CarDamageLog::PATTERN_CAR_DAMAGE_DATE, Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::DEALER_REPORT_DATE:
          Damages_CarDamageLog::logEvent($this->getId(), Damages_CarDamageLog::PATTERN_CAR_DAMAGE_DEALER_REPORT_DATE, Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::DESCRIPTION:
          Damages_CarDamageLog::logEvent($this->getId(), Damages_CarDamageLog::PATTERN_CAR_DAMAGE_DESCRIPTION, Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::DICT_PERPETRATOR_ID:
          Damages_CarDamageLog::logEvent($this->getId(), Damages_CarDamageLog::PATTERN_CAR_DAMAGE_PERPETRATOR, Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::LS_ID:
          $ls = DamagesUsersQuery::create()->findOneById($this->getLsId());
          Damages_CarDamageLog::logEvent($this->getId(), sprintf(Damages_CarDamageLog::PATTERN_CAR_DAMAGE_DESCRIPTION, $ls->getFirstName(), $ls->getLastName()), Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::PERPETRATOR_REPORT_DATE:
          Damages_CarDamageLog::logEvent($this->getId(), Damages_CarDamageLog::PATTERN_CAR_DAMAGE_PERPETRATOR_REPORT_DATE, Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::RELATED_CAR_DAMAGE:
          Damages_CarDamageLog::logEvent($this->getId(), sprintf(Damages_CarDamageLog::PATTERN_CAR_DAMAGE_RELATED_DAMAGE, $this->getRelatedCarDamage()), Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        case DamagesCarDamagesPeer::STATUS_ID:
          $status = DamagesDictStatusesQuery::create()->findOneById($this->getStatusId());
          Damages_CarDamageLog::logEvent($this->getId(), sprintf(Damages_CarDamageLog::PATTERN_CAR_DAMAGE_STATUS, $status->getName()), Damages_CarDamageLog::NAME_BASIC_CAR_DAMAGE_DATA);
          break;
        default:
          break;
      }
    }
  }

}
